package com.example.hospitalbakcends.utils;


import com.example.hospitalbakcends.domain.Doctor;
import jakarta.servlet.http.HttpServletRequest;

import static com.example.hospitalbakcends.constant.DoctorConstant.*;

public class RoleCheck {
    //是否是管理员
    public static boolean isAdmin(HttpServletRequest httpServletRequest){
        Object userObject =httpServletRequest.getSession().getAttribute(USER_LOGIN_STATE);
        Doctor doctor = (Doctor) userObject;
        return doctor != null && doctor.getDoctorrole().equals(ADMIN_ROLE);
    }

    //是否是医生
    public static boolean isParent(HttpServletRequest httpServletRequest){
        Object userObject =httpServletRequest.getSession().getAttribute(USER_LOGIN_STATE);
        Doctor tbUser = (Doctor) userObject;
        return tbUser != null && tbUser.getDoctorrole().equals(DOCTOR_ROLE);
    }
}
